<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>地点展示</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
    <link rel="stylesheet" href="../css/base.css" />
    <style type="text/css">
       .content-block p{
          font-size:.9752381rem;
          line-height: 1.96285714rem;
          color: #333;
          margin-left: 7.5rem;
          text-align: left;    
        }
    </style>
</head>

<body>
    <div id="container"></div>
    <div class="boxfall open-about">
        <img src="../img/tianqi.png">
    </div>
    <!-- 上滑 -->
    <div class="popupself">
        <div class="modelop"></div>
        <div class="content-block">
            <h3 class="bottom-line">天气查询</h3>
            <p class="city"></p>
            <p class="weather"></p>
            <p class="temperature"></p>
            <p class="winddirection"></p>
            <p class="humidity"></p>
            <a href="BUS.html" class="button button-fill button-defau" >规划最佳路线</a>
        </div>
    </div>
</body>

</html>
<script src="http://webapi.amap.com/maps?v=1.4.1&key=b924bdcb52ba818af5dc34c21ba657fa&plugin=AMap.PlaceSearch"></script>
<script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
<script src="../js/gaode_map.js" type="text/javascript" charset="utf-8"></script>
<script type='text/javascript' src='../js/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../plugins/sui/js/sui-mobile.js' charset='utf-8'></script>
<script type='text/javascript' src='../js/app.js' charset='utf-8'></script>
<script type='text/javascript' src='../js/Public_page.js' charset='utf-8'></script>
<script>
$(function() {
     //地理逆编码
    
    eflower_location.Gdlocation(function(data) {
        var map = new AMap.Map('container', {
            resizeEnable: true,
            center: [data.position.getLng(), data.position.getLat()],
            zoom: 13
        });
        map.clearMap(); // 清除地图覆盖物
        var markers = JSON.parse(localStorage.getItem('mark'));
        console.log(markers == null)
        if (markers == null) {
            $.alert('请选择要景点展示');
            return false;
        } else if (markers.length == 0) {
            $.alert('请选择要景点展示');
            return false;
        } else {
            // 添加一些分布不均的点到地图上,地图上添加三个点标记，作为参照
            regeocoder(markers[0].position)
            markers.forEach(function(marker) {
                new AMap.Marker({
                    map: map,
                    icon: marker.icon,
                    position: [marker.position[0], marker.position[1]],
                    offset: new AMap.Pixel(-12, -36)
                });
            });
            // 使地图自适应显示到合适的范围
            var newCenter = map.setFitView();
        }

    });


    function regeocoder(val) { //逆地理编码
            var geocoder = new AMap.Geocoder({
                radius: 1000,
                extensions: "all"
            });
            geocoder.getAddress(val, function(status, result) {
                if (status === 'complete' && result.info === 'OK') {
                    geocoder_CallBack(result);
                }
            });
        }
    function geocoder_CallBack(data) {
            // var address = data.regeocode.formattedAddress; //返回地址描述
            console.log(data)
            var city=(data.regeocode.addressComponent.city);
            localStorage.setItem('city', city)
            var code=data.regeocode.addressComponent.adcode;
            // &extensions=all
            app.ajax('http://restapi.amap.com/v3/weather/weatherInfo?key=1c0a4d40cc2f6469e0ae50f865153f9b&city='+code,'GET',{},function(res){
                if(res.infocode=="10000"){
                    // var data=res.forecasts[0].casts;
                    var data=res.lives[0];
                    console.log(data.province)
                    console.log(data.city)
                    console.log(data.weather)
                    console.log(data.temperature)//气温
                    console.log(data.windpower)//白天风力
                    console.log(data.humidity)//空气湿度
                    console.log(data.winddirection)//方向

                    $('.city').html(city+" "+data.province)
                    $('.weather').html("天气："+data.weather)
                    $('.temperature').html("气温："+data.temperature)
                    $('.winddirection').html("风速："+data.winddirection+"风 "+data.windpower+"级")
                    $('.humidity').html("湿度："+data.humidity+"%")

                }
            })
        }
})
</script>